package com.yswee.framework.utils;

import java.util.Collection;

public class ClassUtils {

	/** 判断是否是值类型 **/
	public static boolean isSingle(Class<?> clazz) {
		return isBoolean(clazz) || isNumber(clazz) || isString(clazz);
	}

	/** 是否布尔值 **/
	public static boolean isBoolean(Class<?> clazz) {
		return (clazz != null)
		&& ((Boolean.TYPE.isAssignableFrom(clazz)) || (Boolean.class
		.isAssignableFrom(clazz)));
	}

	/** 是否数值 **/
	public static boolean isNumber(Class<?> clazz) {
		return (clazz != null)
				&& ((Byte.TYPE.isAssignableFrom(clazz))
						|| (Short.TYPE.isAssignableFrom(clazz))
						|| (Integer.TYPE.isAssignableFrom(clazz))
						|| (Long.TYPE.isAssignableFrom(clazz))
						|| (Float.TYPE.isAssignableFrom(clazz))
						|| (Double.TYPE.isAssignableFrom(clazz)) || (Number.class
				.isAssignableFrom(clazz)));
	}

	/** 判断是否是字符串 **/
	public static boolean isString(Class<?> clazz) {
		return (clazz != null)
		&& ((String.class.isAssignableFrom(clazz))
		|| (Character.TYPE.isAssignableFrom(clazz)) || (Character.class
		.isAssignableFrom(clazz)));
	}

	/** 判断是否是对象 **/
	public static boolean isObject(Class<?> clazz) {
		return clazz != null && !isSingle(clazz) && !isArray(clazz)
				&& !isCollection(clazz);
	}

	/** 判断是否是数组 **/
	public static boolean isArray(Class<?> clazz) {
		return clazz != null && clazz.isArray();
	}

	/** 判断是否是集合 **/
	public static boolean isCollection(Class<?> clazz) {
		return clazz != null && Collection.class.isAssignableFrom(clazz);
	}
	
}
